﻿using QWManage.Model;
using QWManage.Utils;
using System;
using System.Windows.Forms;

namespace QWManage.Forms
{
    public partial class FrmDate : Form
    {
        public FrmDate()
        {
            InitializeComponent();
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            DateConfigInfo dateConfigInfo = new DateConfigInfo();
            dateConfigInfo.From = dtFrom.Value;
            dateConfigInfo.To = dtTo.Value;
            if (dateConfigInfo.From > dateConfigInfo.To)
            {
                Common.MessageBoxWarning("开始日期不能大于结束日期");
                return;
            }
            DateConfigMgr.Set(dateConfigInfo);
            DialogResult = DialogResult.OK;
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            DialogResult = DialogResult.Cancel;
        }

        private void FrmDate_Load(object sender, EventArgs e)
        {
            DateConfigInfo dateConfigInfo = DateConfigMgr.Get();
            dtFrom.Value = dateConfigInfo.From;
            dtTo.Value = dateConfigInfo.To;
        }
    }
}
